import { _decorator, Label, Node, tween, Tween } from 'cc';
import { BasePopUp } from '../../../frame/component/ui.pop-up';
import type { Popup } from '../page/pop-up';
const { ccclass, property } = _decorator;

@ccclass('ppVictory')
export class ppVictory extends BasePopUp<typeof Popup, null> {
	protected default_return: null;

	private node_light: Node;
	private lbl_head: Label;
	private lbl_round: Label;

	protected initAfterOnLoad(){
		this.init();
	}

	public onShow(round: number){
		this.lbl_round.string = 'Level '+round;
		BasePopUp.jelly_enter(this.node);
		Tween.stopAllByTarget(this.node_light);

		tween(this.node_light).set({angle: 0})
		.to(5, {angle: -360}).union()
		.repeatForever().start();

		mtec.delay(1.5, ()=>{
			BasePopUp.jelly_leave(this.node);
			Tween.stopAllByTarget(this.node_light);
			this.node_light.angle = 0;
			this.close(null);
		});
	}

	private init(){
		this.node_light = this.node.getChildByName('background-light');
		this.lbl_head = this.node.getChildByName('lbl-head').getComponent(Label);
		this.lbl_round = this.node.getChildByName('lbl-round').getComponent(Label);

		this.lbl_head.string = 'Success!'
	}
}

